//无参数GET请求
var xmlHttp;
var local="http://47.104.10.151";

//通过鼠标点击事件创建HTTP请求
function onClickAjax() {
    xmlHttp = createXMLHttp();
    var name = document.getElementById("user_name").value;
    email = document.getElementById("email").value;
    password = document.getElementById("password").value;
    nick = document.getElementById("nick").value;
    type = document.getElementById("type").value;
    txt = "name=" + name + "&email=" + email + "&password=" + password + "&nick=" + nick + "&user_type=" + type;
    var url = local+":8080/login/addUser";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束

}

//适配浏览器
//根据不同浏览器发送不同请求
function createXMLHttp() {
    //使用大部分浏览器
    var xmlHttp;
    if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
    }
    if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        if(!xmlHttp){
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    return xmlHttp;
}